package BLC

type Blockchain struct {
	Blocks []*Block
	
}

// 1. 创建带有创世区块的区块链
func CreatBlockchain() *Blockchain {
	genesisBlock := CreateGenesisBlock("Genesis Data....")
	return &Blockchain{[]*Block{genesisBlock}}
}

// 2. 增加区块到区块链中
func (blc *Blockchain) AddBlockToBlockchain(data string)  {
	height := int64(len(blc.Blocks))+1
	preHash := blc.Blocks[len(blc.Blocks)-1].Hash
	newBlock := NewBlock(data,height,preHash)
	blc.Blocks = append(blc.Blocks,newBlock)
}


